package m.jclecai.com.adapter.holder;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import m.jclecai.com.R;
import m.jclecai.com.bean.reconmend.ReconmentPerson;
import m.jclecai.com.data.Lecai_SDK;
import m.jclecai.com.fragment.RecommendFragment;
import m.jclecai.com.listener.Callback;
import m.jclecai.com.view.rounded.RoundedImageView;

/**
 * Created by ZD on 2017/7/19.
 */

public class RmfamousListHolder extends RecyclerView.ViewHolder {
    @BindView(R.id.iv_icon)
    RoundedImageView ivIcon;
    @BindView(R.id.tv_nick)
    TextView tv_nick;
    @BindView(R.id.tv_position)
    TextView tv_position;
    @BindView(R.id.tv_num)
    TextView tv_num;
    @BindView(R.id.iv_imgtype)
    ImageView ivType;
    @BindView(R.id.iv_position)
    ImageView ivPosition;
    private Callback mCallback;
    private ReconmentPerson rp;

    Map<String,Integer> map = new HashMap<String,Integer>(){{
        put("彩票分析师",R.mipmap.famous_cpfxs);
        put("篮球名将",R.mipmap.famous_lqmj);
        put("篮球名人",R.mipmap.famous_lqmr);
        put("媒体名记",R.mipmap.famous_mtmj);
        put("社区名人",R.mipmap.famous_sqmr);
        put("TV大咖",R.mipmap.famous_tvdk);
        put("足球名将",R.mipmap.famous_zqmj);
        put("专业玩家",R.mipmap.famous_zywj);
    }};

    public RmfamousListHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this,itemView);
    }

    public void init(Callback mCallback, ReconmentPerson person){
        this.mCallback = mCallback;
        rp = person;
        Glide.with(itemView.getContext()).
                load(person.getUser_face()).
                asBitmap().
                placeholder(R.drawable.my_head_de).
                into(ivIcon);
        tv_nick.setText(person.getUsername());
        tv_position.setText(person.getTags());
//        int jtype = obj.getIntValue("jtype");
        int jtype = 0;
        ivType.setImageResource(jtype == 0 ? R.mipmap.home_living_football : R.mipmap.home_living_basketball);
        ivPosition.setImageResource(map.get("社区名人"));
        tv_num.setText("解读"+person.getPros());
    }

    @OnClick(R.id.ll_body)
    void toRmDetail(){
        if(mCallback != null)
            Lecai_SDK.persion_id = rp.getUser_id();
            mCallback.callback(RecommendFragment.JUMP.RmFamousActivity);
    }
}
